<template>
  <div>
    <transition name="fade">
      <slot v-if="isExpanded"></slot>
    </transition>
  </div>
</template>

<script>
export default {
  props: {
    value: Boolean,
  },
  data() {
    return {
      isExpanded: this.value,
    };
  },
  watch: {
    value(val) {
      this.isExpanded = val;
    },
  },
  methods: {},
};
</script>

<style scoped>
/* 过渡效果样式 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
</style>
